import * as Types from './mutations-type.js'
import {
  findTypeList,
  findTagList,
  findRecommendList,
  findArchivesBlogList,
  findCarouselList,
} from 'service'

export default {
  // 设置博客分类
  async [Types.SET_CATEGORY]({ commit }) {
    let result = await findTypeList()
    commit(Types.SET_CATEGORY, result.data.data)
  },

  // 设置博客标签
  async [Types.SET_TAG]({ commit }) {
    let result = await findTagList(1, 0)
    commit(Types.SET_TAG, result.data.data.list)
  },

  // 设置最新推荐
  async [Types.SET_RECOMMEND]({ commit }) {
    let result = await findRecommendList()
    commit(Types.SET_RECOMMEND, result.data.data)
  },

  // 设置归档列表
  async [Types.SET_ARCHIVES]({ commit }) {
    let result = await findArchivesBlogList()
    commit(Types.SET_ARCHIVES, result.data.data.list)
  },

  // 设置轮播图
  async [Types.SET_CAROUSEL]({ commit }) {
    let result = await findCarouselList()
    commit(Types.SET_CAROUSEL, result.data.data)
  }
}
